package com.travelparadise.dao;

import java.util.Collection;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.travelparadise.domain.Hotel;
import com.travelparadise.domain.Ville;

public class HotelDaoHibernate extends HibernateDaoSupport implements HotelDao {

	@Override
	public Hotel getById(int id) {
		HibernateTemplate hibernateTemplate = this.getHibernateTemplate();
		
		return (Hotel)hibernateTemplate.get(Hotel.class, id);
	}

	@Override
	public Collection<Hotel> searchByName(String name) {
		String reqHQL ="select h from Hotel as h where h.nom ='"+name+"'";
		return this.getHibernateTemplate().find(reqHQL);
	}

	@Override
	public Collection<Hotel> searchByVille(Ville maville) {
		String reqHQL ="select h from Hotel as h where h.ville.id ="+maville.getId();
		return this.getHibernateTemplate().find(reqHQL);
	}

}
